import { createRouter, createWebHashHistory } from 'vue-router'
import store from '@/store'
import Index from '@/layout/index.vue'
import YeKuo from './modules/YeKuo'
import PermissionListRouter from './modules/PermissionList'
import RoleListRouter from './modules/RoleList'
import DeptManagerRouter from './modules/DeptManager'
import UserManageRouter from './modules/UserManage'
import AclManagerRouter from './modules/AclManager'
import week from './modules/Daily95598'
import Daily from './modules/Daily12398'
// import DailyYk from './modules/DailyYk'
// import DailyGk from './modules/DailyGk'
// import DailyAppeal from './modules/DailyAppeal'
// import DailyTimePeriod from './modules/DailyTimePeriod'
import CustomerWeeklyReport from './modules/CustomerWeeklyReport'
import month from './modules/DailyNews'
import WorkOrder from './modules/WorkOrder'
import AppealData from './modules/AppealData'
import FaultReport from './modules/FaultReport'
import SubWorkOrder from './modules/SubWorkOrder'
import HighVoltage from './modules/HighVoltage'
import LowVoltage from './modules/LowVoltage'
import ReportTicket from './modules/ReportTicket'
import PowerOutEvent from './modules/PowerOutEvent'
import BusinessExpansion from './modules/BusinessExpansion'
import RemoveData from './modules/RemoveData'
import DataGenerator from './modules/DataGenerator'
import LabelManager from './modules/LabelManager'
import LabelPortrait from './modules/LabelPortrait'
import OvertimDetails from './modules/OvertimDetails'
import specialreport from './modules/Specialreport'
import Followuptrackingorder from './modules/Followuptrackingorder'



export const privateRoutes = [
  UserManageRouter,
  RoleListRouter,
  PermissionListRouter,
  DeptManagerRouter,
  AclManagerRouter,
  YeKuo,
  month,
  week,
  CustomerWeeklyReport,
  Daily,
  WorkOrder,
  AppealData,
  FaultReport,
  SubWorkOrder,
  HighVoltage,
  LowVoltage,
  ReportTicket,
  PowerOutEvent,
  BusinessExpansion,
  RemoveData,
  DataGenerator,
  // DailyYk,
  // DailyGk,
  // DailyNews,
  // DailyAppeal,
  // DailyTimePeriod,
  // DailyYkOrder,
  LabelManager,
  LabelPortrait,
  OvertimDetails,
  specialreport,
  Followuptrackingorder,
  

]

export const publicRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index')
  },
  {
    path: '/',
    redirect: '/profile',
    name: 'Index',
    component: Index,
    children: [
      // {
      //   path: '/permission',
      //   name: 'permissionManager',
      //   component: () => import('@/views/permission-list/index.vue')
      // },
      // {
      //   path: '/user/acl',
      //   name: 'aclManager',
      //   component: () => import('@/views/acl-list/index.vue'),
      //   meta: {
      //     title: '权限点列表',
      //     icon: 'personnel'
      //   }
      // },
      {
        path: '/home',
        name: 'homepage',
        component: () => import('@/views/home-page/index2.vue'),
        meta: {
          title: '主页',
          icon: 'home'
        }
      },
      {
        path: '/404',
        name: '404',
        component: () => import('@/views/error-page/404.vue')
      },
      {
        path: '/401',
        name: '401',
        component: () => import('@/views/error-page/401.vue')
      }
    ]
  }
]

/**
 * 初始化路由表
 */
export function resetRouter() {
  if (
      store.getters.userInfo &&
      store.getters.userInfo.menus
  ) {
    const menus = store.getters.userInfo.menus
    menus.forEach((menu) => {
      router.removeRoute(menu)
    })
  }
}

const router = createRouter({
  history: createWebHashHistory(import.meta.env.VITE_API_URL),
  routes: publicRoutes
})

export default router
